DROP DATABASE IF EXISTS `mingyue_springcloud_config`;

CREATE DATABASE  `mingyue_springcloud_config` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

USE mingyue_springcloud_config;

SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for config_info
-- ----------------------------
DROP TABLE IF EXISTS `config_info`;
CREATE TABLE `config_info` (
                               `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
                               `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
                               `group_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                               `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'content',
                               `md5` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'md5',
                               `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                               `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
                               `src_user` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'source user',
                               `src_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'source ip',
                               `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                               `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '租户字段',
                               `c_desc` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                               `c_use` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                               `effect` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                               `type` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                               `c_schema` text CHARACTER SET utf8 COLLATE utf8_bin,
                               `encrypted_data_key` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '秘钥',
                               PRIMARY KEY (`id`),
                               UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';

-- ----------------------------
-- Records of config_info
-- ----------------------------
BEGIN;
INSERT INTO `config_info` VALUES (1, 'application-common.yml', 'DEFAULT_GROUP', '# 通用配置\nspring:\n    # Redis配置 （SSO模式一和模式二使用Redis来同步会话）\n    redis:\n        # Redis数据库索引（默认为0）\n        database: 1\n        # Redis服务器地址\n        host: mingyue-redis\n        # Redis服务器连接端口\n        port: 6379\n        # Redis服务器连接密码(如没有密码请注释掉)\n        # password:\n        # 连接超时时间\n        timeout: 10s\n        ssl: false\n\n# redisson 配置\nredisson:\n  # redis key前缀\n  keyPrefix:\n  # 线程池数量\n  threads: 4\n  # Netty线程池数量\n  nettyThreads: 8\n  # 单节点配置\n  singleServerConfig:\n    # 客户端名称\n    clientName: ${spring.application.name}\n    # 最小空闲连接数\n    connectionMinimumIdleSize: 8\n    # 连接池大小\n    connectionPoolSize: 32\n    # 连接空闲超时，单位：毫秒\n    idleConnectionTimeout: 10000\n    # 命令等待超时，单位：毫秒\n    timeout: 3000\n    # 发布和订阅连接池大小\n    subscriptionConnectionPoolSize: 50\n\n# Sa-Token 配置\nsa-token:\n    # token名称 (同时也是cookie名称)\n    token-name: Authorization\n    # token 生成设置风格（随机32位字符串）\n    token-style: random-32\n    # OAuth2.0 配置\n    oauth2:\n        is-code: true\n        is-implicit: false\n        is-password: false\n        is-client: false\n\n# MyBatis-Plus 配置\nmybatis-plus:\n    # 不支持多包, 如有需要可在注解配置 或 提升扫包等级\n    # 例如 com.**.**.mapper\n    mapperPackage: com.csp.mingyue.**.mapper\n    # 对应的 XML 文件位置\n    mapperLocations: classpath*:/mapper/*Mapper.xml\n    # 实体扫描，多个package用逗号或者分号分隔\n    typeAliasesPackage: com.csp.mingyue.**.domain\n    # 启动时是否检查 MyBatis XML 文件的存在，默认不检查\n    checkConfigLocation: false\n    configuration:\n        # 自动驼峰命名规则（camel case）映射\n        mapUnderscoreToCamelCase: true\n        # MyBatis 自动映射策略\n        # NONE：不启用 PARTIAL：只对非嵌套 resultMap 自动映射 FULL：对所有 resultMap 自动映射\n        autoMappingBehavior: PARTIAL\n        # MyBatis 自动映射时未知列或未知属性处理策\n        # NONE：不做处理 WARNING：打印相关警告 FAILING：抛出异常和详细信息\n        autoMappingUnknownColumnBehavior: NONE\n        # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl\n        # 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl\n        # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl\n        logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl\n    global-config:\n        # 是否打印 Logo banner\n        banner: true\n        dbConfig:\n            # 主键类型\n            # AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID\n            idType: ASSIGN_ID\n            # 逻辑已删除值\n            logicDeleteValue: 1\n            # 逻辑未删除值\n            logicNotDeleteValue: 0\n            insertStrategy: NOT_NULL\n            updateStrategy: NOT_NULL\n            where-strategy: NOT_NULL\n\n# swagger配置\nswagger:\n    enabled: true\n    title: MingYue Swagger API\n    gateway: http://${GATEWAY_HOST:mingyue-gateway}:${GATEWAY-PORT:7100}\n    info:\n        # 标题\n        title: MingYue 基础服务中心_接口文档\n        # 描述\n        description: 基础服务中心\n        # 版本\n        version: 1.5.0\n        # 作者信息\n        contact:\n            name: Strive\n            email: 732171109@qq.com\n            url: https://gitee.com/csps/mingyue\n    components:\n        # 鉴权方式配置\n        security-schemes:\n            apiKey:\n                type: APIKEY\n                in: HEADER\n                name: ${sa-token.token-name}\n    services:\n        mingyue-springcloud-system-biz: system\n        mingyue-springcloud-auth: auth\n        mingyue-springcloud-push-biz: push\n        mingyue-springcloud-oss-biz: oss\n        mingyue-springcloud-search-biz: search\n\n# feign 配置\nfeign:\n  # 启用 okhttp 作为网络请求框架      \n  okhttp:\n    enabled: true\n  # 关闭 httpclient 作为网络请求框架\n  httpclient:\n    enabled: false\n  client:\n    config:\n      # 将调用的微服务名称改成 default 就配置成全局的了\n      default:\n        # 相当于 Request.Optionsn 连接超时时间\n        connectTimeout: 10000\n        # 相当于 Request.Options 读取超时时间\n        readTimeout: 10000\n  compression:\n    request:\n      # 配置请求 GZIP 压缩\n      enabled: true\n    response:\n      # 配置响应 GZIP 压缩\n      enabled: true\n\n# 暴露监控端点\nmanagement:\n  endpoints:\n    web:\n      exposure:\n        include: \'*\'\n  endpoint:\n    health:\n      show-details: ALWAYS\n    logfile:\n      external-file: ./logs/${spring.application.name}/console.log', 'e8263efb3f019a4ca8363c2995297449', '2022-01-09 15:18:55', '2023-12-27 16:35:55', 'nacos', '10.0.2.2', '', 'dev', '通用配置基础配置', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (2, 'mingyue-springcloud-gateway.yml', 'DEFAULT_GROUP', '# 网关中心配置\nspring:\n    cloud:\n        # 网关配置\n        gateway:\n            # 打印请求日志(自定义)\n            requestLog: true\n            discovery:\n                locator:\n                    enabled: true\n            routes:\n                # 认证中心\n                - id: mingyue-springcloud-auth\n                  uri: lb://mingyue-springcloud-auth\n                  predicates:\n                      - Path=/auth/**\n                  filters:\n                      - StripPrefix=1\n                # 系统服务\n                - id: mingyue-springcloud-system-biz\n                  uri: lb://mingyue-springcloud-system-biz\n                  predicates:\n                      - Path=/system/**\n                  filters:\n                      - StripPrefix=1\n                # 推送服务\n                - id: mingyue-springcloud-push-biz\n                  uri: lb://mingyue-springcloud-push-biz\n                  predicates:\n                      - Path=/push/**\n                  filters:\n                      - StripPrefix=1\n                # 文件服务\n                - id: mingyue-springcloud-oss-biz\n                  uri: lb://mingyue-springcloud-oss-biz\n                  predicates:\n                      - Path=/oss/**\n                  filters:\n                      - StripPrefix=1\n                # 固定路由转发配置 无修改\n                - id: openapi\n                  uri: lb://mingyue-springcloud-gateway\n                  predicates:\n                     - Path=/v3/api-docs/**\n                  filters:\n                     - RewritePath=/v3/api-docs/(?<path>.*), /$\\{path}/v3/api-docs\n\nswagger:\n  basic:\n    # 是否开启接口文档密码校验\n    enabled: false\n    username: mingyue\n    password: mingyue\n\n# 安全配置\nsecurity:\n  # 不校验白名单\n  ignore:\n    whites:\n      - /**/v3/api-docs\n      - /v3/api-docs/**\n      - /webjars/**\n      - /auth/oauth2/**\n      - /auth/logout\n      - /auth/login\n      - /auth/smsLogin\n      - /auth/emailLogin\n      - /auth/register\n      - /push/sms/code\n      - /push/email/code\n', 'bd04ab5f9beec6293fb649dab431aa39', '2022-01-09 15:19:07', '2023-09-08 15:22:43', 'nacos', '10.0.2.2', '', 'dev', '', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (3, 'mingyue-springcloud-auth.yml', 'DEFAULT_GROUP', '# 认证中心配置\n', '76f821da0a97b2125161fd961a8257a7', '2022-01-09 15:19:43', '2023-09-07 10:50:58', 'nacos', '10.0.2.2', '', 'dev', '安全服务', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (4, 'mingyue-springcloud-system-biz.yml', 'DEFAULT_GROUP', '# 系统服务配置\nspring:\n    datasource:\n        type: com.zaxxer.hikari.HikariDataSource\n        driver-class-name: com.mysql.cj.jdbc.Driver\n        username: root\n        password: mingyue\n        url: jdbc:mysql://mingyue-mysql:3306/mingyue_springcloud?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n\n# 用户配置\nuser:\n  password:\n    # 私钥\n    salt: $2a$12$pBVti6NTcVJxptxHNqetBe\n', 'ba9c05d8845a1612a23a73041719abc4', '2023-06-06 20:43:20', '2023-09-07 10:51:16', 'nacos', '10.0.2.2', '', 'dev', '', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (5, 'mingyue-springcloud-push-biz.yml', 'DEFAULT_GROUP', '# 推送服务配置\n # 短信配置\nsms:\n  enabled: false\n  # 阿里云 dysmsapi.aliyuncs.com\n  # 腾讯云 sms.tencentcloudapi.com\n  endpoint: \"dysmsapi.aliyuncs.com\"\n  accessKeyId: xxxxxxx\n  accessKeySecret: xxxxxx\n  signName: MingYue基础服务\n  sdkAppId: \n\nemail:\n  enabled: false\n  host: smtp.qq.com\n  port: 465\n  # 是否需要用户名密码验证\n  auth: true\n  # 发送方，遵循RFC-822标准\n  from: xxxxxx@qq.com\n  # 用户名（注意：如果使用foxmail邮箱，此处user为qq号）\n  user: xxxxxx@qq.com\n  # 密码（注意，某些邮箱需要为SMTP服务单独设置密码，详情查看相关帮助）\n  pass: xxxxxx\n  # 使用 STARTTLS安全连接，STARTTLS是对纯文本通信协议的扩展。\n  starttlsEnable: true\n  # 使用SSL安全连接\n  sslEnable: true\n  # SMTP超时时长，单位毫秒，缺省值不超时\n  timeout: 0\n  # Socket连接超时值，单位毫秒，缺省值不超时\n  connectionTimeout: 0\n\n--- # rocketmq 配置\nspring:\n  cloud:\n    stream:\n      function:\n        # 重点配置 与 binding 名与消费者对应\n        definition: rocketmqDemo\n      rocketmq:\n        binder:\n            # rocketmq 地址\n            name-server: 192.168.21.32:9876\n        bindings:\n            rocketmqDemo-out-0:\n                producer:\n                    # 必须得写\n                    group: default\n      bindings:\n        rocketmqDemo-out-0:\n            content-type: application/json\n            destination: stream-rocketmq-demo-topic\n            group: demo-group\n            binder: rocketmq\n        rocketmqDemo-in-0:\n            content-type: application/json\n            destination: stream-rocketmq-demo-topic\n            group: demo-group\n            binder: rocketmq\n\n--- # kafka 配置\nspring:\n  cloud:\n    stream:\n      function:\n        # 重点配置 与 binding 名与消费者对应\n        definition: kafkaDemo\n      kafka:\n        binder:\n            brokers: 192.168.21.32:9092\n      bindings:\n        kafkaDemo-out-0:\n            destination: stream-kafka-demo-topic\n            contentType: application/json\n            group: demo-group\n            binder: kafka\n        kafkaDemo-in-0:\n            destination: stream-kafka-demo-topic\n            contentType: application/json\n            group: demo-group\n            binder: kafka\n', 'a004083cccfe0d019f5a6f5666559e2d', '2023-08-24 14:53:24', '2023-09-26 09:56:43', 'nacos', '10.0.2.2', '', 'dev', '', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (6, 'mingyue-springcloud-oss-biz.yml', 'DEFAULT_GROUP', '# 文件服务配置\nspring:\n    datasource:\n      type: com.zaxxer.hikari.HikariDataSource\n      driver-class-name: com.mysql.cj.jdbc.Driver\n      username: root\n      password: mingyue\n      url: jdbc:mysql://mingyue-mysql:3306/mingyue_springcloud?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true\n', 'b04a6ec1bbc9a2f5589a06a371dd8684', '2022-01-09 15:19:43', '2023-09-12 11:23:31', 'nacos', '10.0.2.2', '', 'dev', '文件服务', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (7, 'mingyue-springcloud-search-biz.yml', 'DEFAULT_GROUP', '# 搜索服务配置\neasy-es:\n  # 是否开启EE自动配置\n  enable: true\n  # es连接地址+端口 格式必须为ip:port,如果是集群则可用逗号隔开\n  address : mingyue-es:9200\n  # 默认为http\n  schema: http\n  # 注意ES建议使用账号认证 不使用会报警告日志\n  # 如果无账号密码则不配置此行\n  #username:\n  # 如果无账号密码则不配置此行\n  #password:\n  # 心跳策略时间 单位:ms\n  keep-alive-millis: 18000\n  # 连接超时时间 单位:ms\n  connectTimeout: 5000\n  # 通信超时时间 单位:ms\n  socketTimeout: 5000\n  # 请求超时时间 单位:ms\n  requestTimeout: 5000\n  # 连接请求超时时间 单位:ms\n  connectionRequestTimeout: 5000\n  # 最大连接数 单位:个\n  maxConnTotal: 100\n  # 最大连接路由数 单位:个\n  maxConnPerRoute: 100\n  global-config:\n    # 开启控制台打印通过本框架生成的DSL语句,默认为开启,生产环境建议关闭,以提升少量性能\n    print-dsl: true\n    # 异步处理索引是否阻塞主线程 默认阻塞 数据量过大时调整为非阻塞异步进行 项目启动更快\n    asyncProcessIndexBlocking: true\n    db-config:\n      # 是否开启下划线转驼峰 默认为false\n      map-underscore-to-camel-case: true\n      # id生成策略 customize为自定义,id值由用户生成,比如取MySQL中的数据id,如缺省此项配置,则id默认策略为es自动生成\n      id-type: customize\n      # 字段更新策略 默认为not_null\n      field-strategy: not_null\n      # 默认开启,查询若指定了size超过1w条时也会自动开启,开启后查询所有匹配数据,若不开启,会导致无法获取数据总条数,其它功能不受影响.\n      enable-track-total-hits: true\n      # 数据刷新策略,默认为不刷新\n      refresh-policy: immediate\n      # 是否全局开启must查询类型转换为filter查询类型 默认为false不转换\n      enable-must2-filter: false\n', 'f3bced616ca033bd6f513076a3298e44', '2023-09-17 15:19:43', '2023-09-17 12:47:05', 'nacos', '222.95.111.249', '', 'dev', '搜索服务', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (8, 'mingyue-springcloud-monitor.yml', 'DEFAULT_GROUP', '# 监控中心配置\nspring:\n  security:\n    user:\n      name: mingyue\n      password: 123456\n  boot:\n    admin:\n      ui:\n        title: MingYue 服务监控中心\n', '36bd240b90341f7cde4e402d43ac1369', '2022-01-09 15:19:43', '2023-09-27 14:47:43', 'nacos', '10.0.2.2', '', 'dev', '监控中心', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (9, 'mingyue-springcloud-xxl-job-admin.yml', 'DEFAULT_GROUP', '# 任务调度配置\n# server 配置\nspring:\n  datasource:\n    type: com.zaxxer.hikari.HikariDataSource\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://mingyue-mysql:3306/mingyue_springcloud_job?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true\n    username: root\n    password: mingyue\n    hikari:\n      auto-commit: true\n      connection-test-query: SELECT 1\n      connection-timeout: 10000\n      idle-timeout: 30000\n      max-lifetime: 900000\n      maximum-pool-size: 30\n      minimum-idle: 10\n      pool-name: HikariCP\n      validation-timeout: 1000\n  mail:\n    from: xxx@qq.com\n    host: smtp.qq.com\n    username: xxx@qq.com\n    password: xxx\n    port: 25\n    properties:\n      mail:\n        smtp:\n          auth: true\n          socketFactory:\n            class: javax.net.ssl.SSLSocketFactory\n          starttls:\n            enable: true\n            required: true\n\n# mybatis 配置\nmybatis:\n  mapper-locations: classpath:/mybatis-mapper/*Mapper.xml\n\n# Actuator 监控端点的配置项\nmanagement:\n  health:\n    mail:\n      enabled: false\n  endpoints:\n    web:\n      exposure:\n        include: \'*\'\n  endpoint:\n    health:\n      show-details: ALWAYS\n    logfile:\n      external-file: ./logs/${spring.application.name}/console.log\n\n# xxljob系统配置\nxxl:\n  job:\n    # 鉴权token\n    accessToken: xxl-job\n    # 国际化\n    i18n: zh_CN\n    # 日志清理\n    logretentiondays: 30\n    triggerpool:\n      fast:\n        max: 200\n      slow:\n        max: 100\n', 'eb86754d1693259d415f397bf43ef8b1', '2022-01-09 15:19:43', '2023-10-25 17:06:09', 'nacos', '10.0.2.2', '', 'dev', '任务调度', '', '', 'yaml', '', '');
INSERT INTO `config_info` VALUES (10, 'mingyue-springcloud-job.yml', 'DEFAULT_GROUP', '# 定时服务配置\nspring:\n  datasource:\n    type: com.zaxxer.hikari.HikariDataSource\n    driver-class-name: com.mysql.cj.jdbc.Driver\n    url: jdbc:mysql://mingyue-mysql:3306/mingyue_springcloud_job?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true\n    username: root\n    password: mingyue\n\nxxl:\n  job:\n    # 执行器开关\n    enabled: true\n    # 调度中心地址：如调度中心集群部署存在多个地址则用逗号分隔。\n    # admin-addresses: http://localhost:9900\n    # 调度中心应用名 通过服务名连接调度中心(启用admin-appname会导致admin-addresses不生效)\n    admin-appName: mingyue-xxl-job-admin\n    # 执行器通讯TOKEN：非空时启用\n    access-token: xxl-job\n    # 执行器配置\n    executor:\n      # 执行器AppName：执行器心跳注册分组依据；为空则关闭自动注册\n      appName: ${spring.application.name}-executor\n      # 29203 端口 随着主应用端口飘逸 避免集群冲突\n      port: 2${server.port}\n      # 执行器注册：默认IP:PORT\n      address:\n      # 执行器IP：默认自动获取IP\n      ip:\n      # 执行器运行日志文件存储磁盘路径\n      logpath: ./logs/${spring.application.name}/xxl-job\n      # 执行器日志文件保存天数：大于3生效\n      logretentiondays: 30\n', '86ab5fa5c32aa2ed0c6f2c52b4df7acc', '2023-03-16 15:19:43', '2023-10-26 11:03:00', 'nacos', '10.0.2.2', '', 'dev', '定时服务', '', '', 'yaml', '', '');
COMMIT;

-- ----------------------------
-- Table structure for config_info_aggr
-- ----------------------------
DROP TABLE IF EXISTS `config_info_aggr`;
CREATE TABLE `config_info_aggr` (
                                    `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
                                    `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
                                    `group_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'group_id',
                                    `datum_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'datum_id',
                                    `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '内容',
                                    `gmt_modified` datetime NOT NULL COMMENT '修改时间',
                                    `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                                    `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '租户字段',
                                    PRIMARY KEY (`id`),
                                    UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段';

-- ----------------------------
-- Records of config_info_aggr
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for config_info_beta
-- ----------------------------
DROP TABLE IF EXISTS `config_info_beta`;
CREATE TABLE `config_info_beta` (
                                    `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
                                    `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
                                    `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'group_id',
                                    `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'app_name',
                                    `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'content',
                                    `beta_ips` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'betaIps',
                                    `md5` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'md5',
                                    `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                    `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
                                    `src_user` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'source user',
                                    `src_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'source ip',
                                    `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '租户字段',
                                    `encrypted_data_key` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '秘钥',
                                    PRIMARY KEY (`id`),
                                    UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';

-- ----------------------------
-- Records of config_info_beta
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for config_info_tag
-- ----------------------------
DROP TABLE IF EXISTS `config_info_tag`;
CREATE TABLE `config_info_tag` (
                                   `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
                                   `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
                                   `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'group_id',
                                   `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT 'tenant_id',
                                   `tag_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'tag_id',
                                   `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'app_name',
                                   `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'content',
                                   `md5` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'md5',
                                   `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                   `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
                                   `src_user` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'source user',
                                   `src_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'source ip',
                                   PRIMARY KEY (`id`),
                                   UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';

-- ----------------------------
-- Records of config_info_tag
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for config_tags_relation
-- ----------------------------
DROP TABLE IF EXISTS `config_tags_relation`;
CREATE TABLE `config_tags_relation` (
                                        `id` bigint NOT NULL COMMENT 'id',
                                        `tag_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'tag_name',
                                        `tag_type` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'tag_type',
                                        `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'data_id',
                                        `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'group_id',
                                        `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT 'tenant_id',
                                        `nid` bigint NOT NULL AUTO_INCREMENT,
                                        PRIMARY KEY (`nid`),
                                        UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
                                        KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';

-- ----------------------------
-- Records of config_tags_relation
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for group_capacity
-- ----------------------------
DROP TABLE IF EXISTS `group_capacity`;
CREATE TABLE `group_capacity` (
                                  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                  `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Group ID，空字符表示整个集群',
                                  `quota` int unsigned NOT NULL DEFAULT '0' COMMENT '配额，0表示使用默认值',
                                  `usage` int unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
                                  `max_size` int unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限，单位为字节，0表示使用默认值',
                                  `max_aggr_count` int unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数，，0表示使用默认值',
                                  `max_aggr_size` int unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限，单位为字节，0表示使用默认值',
                                  `max_history_count` int unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
                                  `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                  `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
                                  PRIMARY KEY (`id`),
                                  UNIQUE KEY `uk_group_id` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表';

-- ----------------------------
-- Records of group_capacity
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for his_config_info
-- ----------------------------
DROP TABLE IF EXISTS `his_config_info`;
CREATE TABLE `his_config_info` (
                                   `id` bigint unsigned NOT NULL,
                                   `nid` bigint unsigned NOT NULL AUTO_INCREMENT,
                                   `data_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
                                   `group_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
                                   `app_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'app_name',
                                   `content` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
                                   `md5` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                                   `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                   `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                   `src_user` text CHARACTER SET utf8 COLLATE utf8_bin,
                                   `src_ip` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                                   `op_type` char(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                                   `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT '租户字段',
                                   `encrypted_data_key` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '秘钥',
                                   PRIMARY KEY (`nid`),
                                   KEY `idx_gmt_create` (`gmt_create`),
                                   KEY `idx_gmt_modified` (`gmt_modified`),
                                   KEY `idx_did` (`data_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';

-- ----------------------------
-- Records of his_config_info
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for permissions
-- ----------------------------
DROP TABLE IF EXISTS `permissions`;
CREATE TABLE `permissions` (
                               `role` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
                               `resource` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
                               `action` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
                               UNIQUE KEY `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

-- ----------------------------
-- Records of permissions
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for roles
-- ----------------------------
DROP TABLE IF EXISTS `roles`;
CREATE TABLE `roles` (
                         `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
                         `role` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
                         UNIQUE KEY `idx_user_role` (`username`,`role`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

-- ----------------------------
-- Records of roles
-- ----------------------------
BEGIN;
INSERT INTO `roles` VALUES ('nacos', 'ROLE_ADMIN');
COMMIT;

-- ----------------------------
-- Table structure for tenant_capacity
-- ----------------------------
DROP TABLE IF EXISTS `tenant_capacity`;
CREATE TABLE `tenant_capacity` (
                                   `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                   `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Tenant ID',
                                   `quota` int unsigned NOT NULL DEFAULT '0' COMMENT '配额，0表示使用默认值',
                                   `usage` int unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
                                   `max_size` int unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限，单位为字节，0表示使用默认值',
                                   `max_aggr_count` int unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数',
                                   `max_aggr_size` int unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限，单位为字节，0表示使用默认值',
                                   `max_history_count` int unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
                                   `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                   `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
                                   PRIMARY KEY (`id`),
                                   UNIQUE KEY `uk_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表';

-- ----------------------------
-- Records of tenant_capacity
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for tenant_info
-- ----------------------------
DROP TABLE IF EXISTS `tenant_info`;
CREATE TABLE `tenant_info` (
                               `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
                               `kp` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'kp',
                               `tenant_id` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT 'tenant_id',
                               `tenant_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT '' COMMENT 'tenant_name',
                               `tenant_desc` varchar(256) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'tenant_desc',
                               `create_source` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT 'create_source',
                               `gmt_create` bigint NOT NULL COMMENT '创建时间',
                               `gmt_modified` bigint NOT NULL COMMENT '修改时间',
                               PRIMARY KEY (`id`),
                               UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
                               KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';

-- ----------------------------
-- Records of tenant_info
-- ----------------------------
BEGIN;
INSERT INTO `tenant_info` VALUES (1, '1', 'dev', 'dev', '开发环境', NULL, 1685431286259, 1685431286259);
INSERT INTO `tenant_info` VALUES (2, '1', 'prod', 'prod', '生产环境', NULL, 1685431286259, 1685431286259);
COMMIT;

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
                         `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
                         `password` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
                         `enabled` tinyint(1) NOT NULL,
                         PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

-- ----------------------------
-- Records of users
-- ----------------------------
BEGIN;
INSERT INTO `users` VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', 1);
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
